<?php

namespace mbilling\BillingBundle\Model;

use Doctrine\ORM\EntityManager;
use mbilling\BillingBundle\Entity\usersTotalTransactions;


Class UsersTotalTransactionsModel
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }
    
    public function findAll()
    {
        $transaction = $this->em->getRepository('BillingBundle:usersTotalTransactions')->findAll();
        return $transaction;
    }
    
    public function findByUserId($user_id)
    {
        $transaction = $this->em->getRepository('BillingBundle:usersTotalTransactions')->findOneBy(array('user_id' => $user_id));
        return $transaction;
    }

    public function create($oEntity)
    {
        $this->em->persist($oEntity);
        $this->em->flush();
    }
    
    public function removeByPK($transaction_id)
    {
        $transaction = $this->em->find('BillingBundle:usersTotalTransactions', $transaction_id);
        $this->em->remove($transaction);
        $this->em->flush();
    } 
}
?>
